/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright 2024-2025 ByteDance and/or its affiliates.
 */

use g3_types::net::TlsServerName;

use crate::parser::tls::{ExtensionType, HandshakeCoalescer, Record, RecordParseError};

const STREAM_BYTES: &[u8] = &[
    0x16, 0x03, 0x01, 0x07, 0x1c, 0x01, 0x00, 0x07, 0x18, 0x03, 0x03, 0x77, 0x6e, 0x9c, 0x10, 0x89,
    0x32, 0x52, 0x85, 0xa1, 0x45, 0xbb, 0xa4, 0x0d, 0x6a, 0x84, 0xa1, 0xc6, 0x25, 0xa0, 0x24, 0x5b,
    0x2c, 0xbf, 0x1b, 0xc3, 0xda, 0x1a, 0x8c, 0x34, 0x8c, 0x36, 0xf3, 0x20, 0x4c, 0xc3, 0x64, 0x68,
    0x64, 0xcc, 0x2a, 0x1b, 0xfb, 0xa2, 0x67, 0xd2, 0x46, 0xed, 0xdb, 0xb3, 0x99, 0x5c, 0x1a, 0x69,
    0xda, 0xb4, 0x29, 0x3d, 0xc8, 0x59, 0x43, 0x96, 0xed, 0xc7, 0xb5, 0x12, 0x00, 0x20, 0x6a, 0x6a,
    0x13, 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2b, 0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30, 0xcc, 0xa9,
    0xcc, 0xa8, 0xc0, 0x13, 0xc0, 0x14, 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f, 0x00, 0x35, 0x01, 0x00,
    0x06, 0xaf, 0xfa, 0xfa, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x2d, 0x00, 0x02, 0x01,
    0x01, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x10, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, 0x05, 0x03, 0x08,
    0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x00, 0x17, 0x00, 0x00, 0x44, 0x69, 0x00, 0x05, 0x00,
    0x03, 0x02, 0x68, 0x32, 0x00, 0x12, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x02,
    0x01, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x02, 0x00, 0x02, 0x00, 0x33, 0x04, 0xef, 0x04, 0xed, 0x5a,
    0x5a, 0x00, 0x01, 0x00, 0x63, 0x99, 0x04, 0xc0, 0x30, 0x13, 0xe7, 0x22, 0xe5, 0xeb, 0xc8, 0x0f,
    0x8e, 0xce, 0xcc, 0xb8, 0x80, 0x63, 0x04, 0xed, 0x83, 0xdd, 0x1b, 0x85, 0x5b, 0xe6, 0x84, 0x80,
    0x77, 0xfd, 0xc4, 0xc6, 0x9f, 0x90, 0x26, 0x07, 0xbb, 0x50, 0xa0, 0x61, 0x69, 0x31, 0xbb, 0xd4,
    0x85, 0x4b, 0x90, 0x3a, 0xd6, 0xd3, 0xa6, 0xab, 0x73, 0x88, 0xac, 0x52, 0x58, 0x6a, 0x98, 0x87,
    0xa7, 0xf9, 0x5d, 0x6f, 0x4b, 0x51, 0xca, 0x04, 0x75, 0x45, 0x88, 0xcf, 0x68, 0x1a, 0xce, 0x6b,
    0x79, 0xca, 0x07, 0x11, 0xcb, 0xc8, 0x16, 0x90, 0x57, 0x38, 0x6d, 0xf0, 0x96, 0x17, 0xbd, 0x65,
    0x8e, 0x26, 0x4c, 0x21, 0x87, 0x5b, 0x83, 0x66, 0x13, 0x7f, 0x34, 0x48, 0x1e, 0x1e, 0x52, 0xb7,
    0x4b, 0x03, 0x98, 0x3f, 0x53, 0xbc, 0x80, 0xbb, 0x08, 0x33, 0xba, 0x30, 0xe7, 0x31, 0x63, 0x04,
    0x20, 0xbd, 0x68, 0x90, 0x90, 0x7e, 0xb5, 0xad, 0x21, 0xba, 0x8f, 0x34, 0x8c, 0x26, 0xf5, 0x34,
    0x47, 0xca, 0x41, 0x53, 0x9a, 0xa9, 0x58, 0xda, 0xc8, 0x09, 0x2b, 0x83, 0x76, 0x11, 0xd7, 0xbd,
    0x4e, 0x5b, 0x86, 0x1b, 0xe4, 0x30, 0x4f, 0x4c, 0x5b, 0xb8, 0x22, 0x24, 0xfe, 0x47, 0x4a, 0xa8,
    0xb4, 0xc0, 0xae, 0xdb, 0x00, 0x18, 0x77, 0x8b, 0xe9, 0x81, 0x98, 0x11, 0x2c, 0x80, 0xef, 0x36,
    0x19, 0xa2, 0xe4, 0xb4, 0x4e, 0xa3, 0x49, 0x81, 0xac, 0xa9, 0xa4, 0xe5, 0x77, 0xd4, 0xd2, 0x77,
    0x32, 0xd6, 0x09, 0xe5, 0x10, 0x3c, 0x12, 0x24, 0xb8, 0x9b, 0x8a, 0x13, 0xaa, 0xa8, 0x07, 0x23,
    0x14, 0xa3, 0x4b, 0x7b, 0x5b, 0x66, 0xd1, 0x79, 0x68, 0xd8, 0x6c, 0xa0, 0x60, 0x9a, 0xa5, 0x2a,
    0xa1, 0xa4, 0x5a, 0x5d, 0xcd, 0xd3, 0x9d, 0xcf, 0xa8, 0x13, 0xae, 0x53, 0x04, 0x99, 0x70, 0x8d,
    0xdc, 0x13, 0x27, 0x4f, 0xd3, 0x5c, 0x8d, 0x95, 0xbf, 0xb7, 0xf7, 0x7f, 0x17, 0x79, 0x10, 0x6a,
    0x82, 0xab, 0x4e, 0xb0, 0x4b, 0x51, 0x39, 0x7d, 0x3c, 0x53, 0x24, 0xb8, 0xbc, 0x9f, 0x0a, 0x32,
    0x9b, 0x0b, 0x8b, 0x32, 0xaa, 0xfa, 0x72, 0x87, 0x10, 0xba, 0x24, 0xa4, 0xb1, 0xa1, 0x95, 0x75,
    0xaa, 0xfa, 0x21, 0x5c, 0xf5, 0x50, 0xdb, 0x37, 0x8f, 0xf9, 0x3a, 0x69, 0x63, 0x53, 0xce, 0x78,
    0x52, 0xc3, 0x01, 0x14, 0x77, 0xf2, 0xe2, 0x65, 0x3a, 0x00, 0xb9, 0x8d, 0x3b, 0x1f, 0x82, 0xd4,
    0xad, 0xfa, 0x85, 0x54, 0x6a, 0x66, 0x31, 0xed, 0xc5, 0x1b, 0x2c, 0xf8, 0x0b, 0x2e, 0x58, 0x90,
    0x31, 0xe2, 0x63, 0xf8, 0x54, 0x11, 0xdc, 0xc8, 0x4b, 0x45, 0xf5, 0x89, 0x96, 0x15, 0x51, 0x52,
    0x22, 0x82, 0x25, 0xdb, 0x1a, 0x58, 0xf6, 0x1b, 0x72, 0xb6, 0x4d, 0x5a, 0xc5, 0x6e, 0x53, 0x22,
    0x0c, 0x3d, 0x56, 0x4d, 0x6d, 0xf0, 0x32, 0x70, 0x31, 0x51, 0x2d, 0x29, 0x5d, 0x5b, 0x77, 0x64,
    0x56, 0xe4, 0xac, 0x86, 0x26, 0x81, 0xb1, 0x23, 0xac, 0x1d, 0x0a, 0x72, 0x38, 0xe4, 0x6a, 0xae,
    0x09, 0x9e, 0x90, 0xa0, 0x37, 0x42, 0x48, 0x38, 0x18, 0x98, 0x61, 0x30, 0xf9, 0x5d, 0x5a, 0x6c,
    0x57, 0xc5, 0xca, 0x58, 0xf4, 0x50, 0x25, 0xba, 0x1b, 0xcd, 0xa4, 0x45, 0x74, 0xd6, 0xea, 0x84,
    0x6b, 0x8c, 0x21, 0x02, 0x29, 0x57, 0xd1, 0x97, 0x95, 0x18, 0x81, 0x64, 0x71, 0x22, 0x79, 0xd0,
    0xb4, 0x78, 0x33, 0x78, 0xcc, 0x98, 0xb8, 0x76, 0x97, 0x9c, 0xc8, 0x94, 0xa3, 0xcc, 0xe0, 0xa1,
    0x0c, 0x0d, 0xb1, 0x08, 0x76, 0x1b, 0x8c, 0xf0, 0xe3, 0x75, 0xfe, 0x79, 0xa3, 0x5e, 0x33, 0x92,
    0x72, 0x65, 0x7b, 0x32, 0xc9, 0x42, 0x47, 0x4b, 0xa4, 0xa3, 0xb2, 0x94, 0x7b, 0x4a, 0x84, 0x7c,
    0x3b, 0x82, 0x30, 0xc7, 0xaf, 0x5a, 0x16, 0x2a, 0x0f, 0xd7, 0xca, 0x24, 0x5c, 0xc4, 0xaf, 0xe4,
    0x95, 0xd3, 0x08, 0x9d, 0x0c, 0xc3, 0xa4, 0x6d, 0x16, 0x71, 0x3f, 0xb4, 0x37, 0x5f, 0x4b, 0x38,
    0xe6, 0xac, 0x89, 0x13, 0xd6, 0x2c, 0x26, 0x3c, 0x84, 0xaa, 0x4a, 0xa6, 0x05, 0xfa, 0x25, 0x1d,
    0xfc, 0xc1, 0x28, 0x46, 0xc0, 0xb3, 0xec, 0x72, 0xec, 0x27, 0x8a, 0xba, 0x40, 0xb3, 0x91, 0xf1,
    0x6c, 0x71, 0xe4, 0x87, 0x44, 0xd7, 0x5e, 0xca, 0xe8, 0x14, 0x7e, 0x70, 0x06, 0x2d, 0xaa, 0x94,
    0xa9, 0x99, 0x7e, 0x25, 0x5a, 0x4c, 0xa4, 0xe1, 0x3f, 0x33, 0xe5, 0x17, 0x4f, 0x14, 0x99, 0x45,
    0x5a, 0x45, 0x7c, 0x14, 0x9c, 0x99, 0x20, 0xa6, 0x02, 0x14, 0x4e, 0x1e, 0xb1, 0x5c, 0x94, 0xa7,
    0x49, 0x93, 0xf8, 0x5b, 0xc3, 0x09, 0x0a, 0x37, 0xbc, 0x61, 0x33, 0x47, 0x3d, 0x7b, 0x5a, 0x75,
    0xab, 0x70, 0x7d, 0x19, 0x29, 0x00, 0x9a, 0x4a, 0x2e, 0xec, 0x15, 0x32, 0x7e, 0x18, 0xc2, 0xaa,
    0x24, 0x57, 0xed, 0x0b, 0x4c, 0x22, 0xd9, 0x7c, 0x5e, 0xfb, 0x5a, 0xfd, 0xb2, 0x30, 0x68, 0x5b,
    0x7e, 0x56, 0x71, 0xb3, 0x4f, 0x54, 0x82, 0x8b, 0x95, 0xa3, 0x58, 0x94, 0xb2, 0xd2, 0xa9, 0x0c,
    0xe0, 0x01, 0x02, 0x07, 0x25, 0x0a, 0x74, 0xa7, 0x0e, 0xf9, 0x91, 0x11, 0xf0, 0x90, 0xc7, 0x11,
    0xc5, 0x20, 0x65, 0xcb, 0x7d, 0x38, 0x23, 0x87, 0xe0, 0x98, 0xa5, 0x15, 0x83, 0xbc, 0xcd, 0x3b,
    0x1e, 0x5e, 0xc8, 0xaf, 0xfd, 0x70, 0xb0, 0x95, 0x35, 0x1d, 0xbc, 0xe9, 0x32, 0xc5, 0x87, 0xc2,
    0x0b, 0xb8, 0x6f, 0xfc, 0x61, 0xc5, 0xe4, 0x09, 0xa7, 0x3d, 0x35, 0x70, 0x27, 0x74, 0xbe, 0xda,
    0xab, 0xad, 0x98, 0xe6, 0x50, 0xc7, 0x60, 0xba, 0xd8, 0xf5, 0x36, 0xe4, 0x13, 0x6a, 0x1b, 0xb5,
    0xb6, 0xfc, 0xe1, 0x59, 0x26, 0xd2, 0x5f, 0xfa, 0x55, 0x36, 0xa9, 0x54, 0x5a, 0x56, 0x26, 0x13,
    0x83, 0x84, 0x6f, 0x76, 0x4c, 0x87, 0x7c, 0x63, 0x95, 0xa0, 0x93, 0x42, 0x23, 0x7c, 0x7f, 0xed,
    0xb8, 0x5e, 0x48, 0xa6, 0xc0, 0xf0, 0x77, 0xb0, 0xb7, 0xd3, 0x32, 0x9c, 0x47, 0x22, 0x41, 0xab,
    0x3d, 0x8b, 0x4c, 0x06, 0x8e, 0x53, 0x48, 0x67, 0x09, 0x67, 0xc8, 0x9c, 0x14, 0x3f, 0x63, 0x55,
    0xa2, 0xec, 0x06, 0xf0, 0x53, 0x6e, 0x67, 0x60, 0x84, 0xb2, 0x45, 0xad, 0x98, 0x8c, 0xc8, 0x4c,
    0xe2, 0x8e, 0xed, 0x68, 0x25, 0xbf, 0xf4, 0x00, 0x35, 0x42, 0x19, 0xba, 0x21, 0xc9, 0x90, 0x1b,
    0xa7, 0x62, 0x70, 0x05, 0xbe, 0xe9, 0x48, 0x8e, 0xc7, 0x21, 0xff, 0xf0, 0x26, 0x5e, 0x82, 0xc0,
    0x15, 0xd2, 0x9c, 0x32, 0xea, 0x1d, 0xaf, 0x3a, 0x25, 0x4c, 0x26, 0x4c, 0xff, 0x41, 0x32, 0xcf,
    0x64, 0x2e, 0xa4, 0xdb, 0x71, 0x05, 0x29, 0x80, 0x8c, 0x3a, 0x2d, 0xed, 0x40, 0x13, 0xc9, 0xa4,
    0x8b, 0xc0, 0x6c, 0x1d, 0xf6, 0x06, 0x54, 0xa7, 0x79, 0x1a, 0x85, 0x70, 0xac, 0xdf, 0x23, 0x3a,
    0x61, 0x70, 0x63, 0x5d, 0x56, 0x9b, 0x66, 0x92, 0xa5, 0x89, 0xe8, 0x93, 0x0e, 0xf8, 0x43, 0xc2,
    0x0b, 0x26, 0x44, 0x08, 0x0e, 0x67, 0x9c, 0xb6, 0x4c, 0x74, 0x2a, 0x17, 0x1b, 0x43, 0x63, 0x70,
    0xb7, 0xb6, 0x36, 0x4e, 0x8b, 0x76, 0xb1, 0x20, 0x98, 0xa3, 0xe8, 0x79, 0x99, 0xff, 0x03, 0x83,
    0xfb, 0x70, 0x39, 0xc3, 0xb9, 0x0d, 0xab, 0xd7, 0xad, 0xdb, 0xf6, 0x88, 0x09, 0x6c, 0x05, 0x8e,
    0xd1, 0xcf, 0x3b, 0x9a, 0x29, 0x06, 0x84, 0xa2, 0xe1, 0x50, 0x99, 0xca, 0x4b, 0xae, 0xb4, 0x2a,
    0x49, 0x0c, 0x46, 0x37, 0x88, 0xf0, 0x39, 0x8c, 0x23, 0x28, 0x26, 0xd9, 0x00, 0x87, 0xf9, 0x73,
    0x01, 0x0b, 0xb0, 0x89, 0x5c, 0x32, 0x97, 0x47, 0x2e, 0xe7, 0x48, 0x93, 0xdb, 0x5a, 0x25, 0x8a,
    0xe8, 0x07, 0xca, 0x18, 0x17, 0x08, 0xb9, 0x31, 0x6a, 0xb4, 0x24, 0x19, 0xcb, 0x90, 0x22, 0xd8,
    0xb2, 0xea, 0xa9, 0x1d, 0x7d, 0x6c, 0x80, 0xb4, 0xd3, 0x29, 0x76, 0x42, 0x7b, 0xbd, 0x4a, 0x49,
    0xc5, 0x45, 0x54, 0x0d, 0x7a, 0x20, 0xce, 0xc0, 0xa7, 0xfb, 0xe0, 0x33, 0x6d, 0x93, 0xae, 0xc2,
    0x2a, 0x6f, 0x61, 0xf9, 0xae, 0xaa, 0x98, 0xba, 0x0a, 0x82, 0x3c, 0x75, 0x1b, 0x7e, 0xaa, 0xa7,
    0x23, 0x78, 0xcc, 0x66, 0x93, 0x76, 0xbb, 0xce, 0x94, 0xa2, 0xad, 0x89, 0x32, 0x64, 0xa2, 0xbb,
    0x54, 0x95, 0x19, 0x87, 0xc2, 0x46, 0x68, 0x71, 0x0e, 0x9e, 0x6a, 0x03, 0x3a, 0xe7, 0x82, 0x63,
    0xe2, 0xa9, 0x27, 0x74, 0xb0, 0x32, 0xe3, 0x48, 0xc3, 0x6b, 0x81, 0x0c, 0x62, 0x5b, 0x84, 0xf2,
    0x6b, 0xab, 0x13, 0x33, 0xfa, 0x92, 0x0a, 0xc3, 0x4a, 0x95, 0x59, 0xf7, 0xb0, 0x4d, 0x03, 0x00,
    0xd7, 0x37, 0x6d, 0xdc, 0xa5, 0x4b, 0xc3, 0xaa, 0x45, 0x03, 0x2a, 0xca, 0xbd, 0xb2, 0x09, 0x18,
    0xe0, 0x17, 0xd6, 0xe1, 0x6e, 0x5a, 0x1a, 0x0c, 0x3a, 0x80, 0xc4, 0x24, 0xab, 0x15, 0x91, 0xa9,
    0x4b, 0x5a, 0xdb, 0x3d, 0xd0, 0x3d, 0x3d, 0x62, 0xb4, 0x5a, 0x9d, 0xe0, 0xf6, 0xda, 0x76, 0x73,
    0xaa, 0xc1, 0x96, 0x0c, 0xaa, 0xc9, 0xde, 0xce, 0x00, 0x1d, 0x00, 0x20, 0x18, 0x0c, 0x54, 0xb7,
    0x23, 0x81, 0xdd, 0xee, 0x3c, 0xe2, 0xcb, 0xb5, 0x6a, 0x98, 0x18, 0xed, 0x42, 0x68, 0x1e, 0x2b,
    0x46, 0xf5, 0xfb, 0x24, 0xc1, 0x78, 0xce, 0x44, 0x1c, 0x86, 0x2f, 0x60, 0x00, 0x10, 0x00, 0x0e,
    0x00, 0x0c, 0x02, 0x68, 0x32, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0xfe, 0x0d,
    0x01, 0x1a, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc5, 0x00, 0x20, 0xb1, 0x3f, 0xeb, 0x88, 0xb9, 0x0e,
    0xf1, 0xb7, 0x87, 0x51, 0x2a, 0xe6, 0x1c, 0xca, 0xe8, 0x18, 0xea, 0x6c, 0xf6, 0x60, 0x21, 0xf8,
    0x36, 0x91, 0x9c, 0x1f, 0xaa, 0x9d, 0x01, 0xd5, 0xab, 0x74, 0x00, 0xf0, 0xf1, 0x39, 0xbb, 0xf5,
    0x15, 0x6a, 0x1d, 0x97, 0xbb, 0xc1, 0x82, 0xd4, 0xc5, 0x24, 0x8a, 0x8b, 0x96, 0xcf, 0x86, 0x2b,
    0xa4, 0x95, 0x69, 0x51, 0xc8, 0xeb, 0xca, 0xac, 0x0a, 0xe4, 0x6e, 0x15, 0x32, 0xa7, 0xfa, 0xdd,
    0x96, 0xd7, 0x0e, 0xa2, 0x79, 0xde, 0x8c, 0xf3, 0xb8, 0xc4, 0x05, 0xa7, 0x7f, 0x68, 0x28, 0x89,
    0xeb, 0x39, 0x9b, 0xe5, 0x0e, 0x96, 0x39, 0xba, 0x80, 0x0e, 0x3c, 0x96, 0x32, 0x42, 0x54, 0x9a,
    0x25, 0xad, 0x16, 0x00, 0x6c, 0x25, 0x8e, 0x8f, 0x84, 0xc1, 0x46, 0xe4, 0x8e, 0x32, 0x6c, 0x8d,
    0x58, 0x9e, 0x22, 0xfe, 0x9e, 0x1a, 0x1c, 0xb3, 0xd1, 0xbc, 0xb6, 0xfe, 0x86, 0x06, 0x6b, 0x52,
    0x5c, 0x7b, 0x49, 0xbb, 0x8a, 0x95, 0x68, 0x52, 0x8b, 0x91, 0x28, 0xf3, 0xad, 0x84, 0x06, 0x23,
    0x14, 0xa3, 0x92, 0x1c, 0x8b, 0x6f, 0x2a, 0xc6, 0x10, 0x74, 0x11, 0x7d, 0xae, 0xbf, 0xe2, 0x84,
    0x60, 0x39, 0xff, 0x01, 0xc4, 0xbf, 0xdf, 0xe0, 0xdd, 0x01, 0xf9, 0x46, 0x00, 0x9e, 0x1b, 0x6e,
    0x3c, 0x7d, 0xc3, 0x1b, 0x87, 0xe2, 0xd4, 0x5d, 0xcb, 0x2b, 0x46, 0xb4, 0x62, 0x89, 0x7d, 0xe5,
    0x32, 0xd8, 0xc4, 0x89, 0x00, 0x3f, 0xa3, 0x50, 0xf8, 0x7b, 0x02, 0x35, 0x04, 0x7d, 0xfa, 0x00,
    0x5a, 0x67, 0x29, 0x4d, 0x52, 0xae, 0xb3, 0x19, 0x36, 0xa9, 0x49, 0xfb, 0x09, 0x46, 0x58, 0x1d,
    0xb0, 0xfb, 0x2c, 0x00, 0xda, 0x0a, 0x3a, 0xa3, 0xaf, 0x65, 0x15, 0x2f, 0x37, 0xbf, 0x4a, 0x93,
    0x31, 0xf3, 0x2d, 0xbb, 0x43, 0x66, 0x78, 0xec, 0x75, 0x97, 0x34, 0x34, 0xf4, 0xcb, 0x70, 0x3c,
    0x7d, 0xcf, 0xeb, 0x83, 0xce, 0xdd, 0xb6, 0xf3, 0x65, 0xcd, 0x7d, 0x04, 0x00, 0x05, 0x00, 0x05,
    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x16, 0x00, 0x00, 0x13, 0x61, 0x63,
    0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
    0x6d, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x0a, 0x5a, 0x5a, 0x63, 0x99, 0x00, 0x1d, 0x00, 0x17, 0x00,
    0x18, 0x00, 0x2b, 0x00, 0x07, 0x06, 0x1a, 0x1a, 0x03, 0x04, 0x03, 0x03, 0x1a, 0x1a, 0x00, 0x01,
    0x00,
];

#[test]
fn sni() {
    // check partial data
    let Err(RecordParseError::NeedMoreData(_)) = Record::parse(&STREAM_BYTES[..100]) else {
        panic!("unexpected error type");
    };
    // check full data
    let mut handshake_coalescer = HandshakeCoalescer::default();
    let mut record = Record::parse(STREAM_BYTES).unwrap();
    let handshake_msg = record
        .consume_handshake(&mut handshake_coalescer)
        .unwrap()
        .unwrap();
    let client_hello = handshake_msg.parse_client_hello().unwrap();
    let sni_bytes = client_hello
        .get_ext(ExtensionType::ServerName)
        .unwrap()
        .unwrap();
    let sni = TlsServerName::from_extension_value(sni_bytes).unwrap();
    assert!(record.consume_done());
    assert_eq!(sni.as_ref(), "accounts.google.com");
}
